// pages/details/details.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:'',
    projectName:'',
    msgBody:'',
    msgDate:'',
    name:'',
    phone:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '消息',
    });
    var that=this
    that.setData({
      id: options.id
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that=this
    wx.request({
      url: app.url + '/consultant/auth3/conMsgTab/getConInfo',
      method: 'POST',
      header: {
        "Content-Type": "application/x-www-form-urlencoded",
        token: wx.getStorageSync('token')
      },
      data: {
        id:that.data.id
      },
      success: (res) => {
        if (res.data.code == 0) {
          this.setData({
            projectName: res.data.data.projectName,
            msgDate: app.dateFormat(res.data.data.msgDate),
            msgBody: res.data.data.msgBody,
            name: res.data.data.name,
            phone: res.data.data.phone
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // 拨打电话
  callGetPhone(e){
    console.log(e.currentTarget.dataset.getphone)
    var phoneNumber = e.currentTarget.dataset.getphone
    this.callPhone(phoneNumber)
  },
  //拨打电话
  callPhone(phoneNumber) {
    wx.makePhoneCall({
      phoneNumber: phoneNumber,
      success: function () {
        console.log("拨打电话成功！")

      },
      fail: function () {
        console.log("拨打电话失败！")

      }
    })

  }
})